package com.wulian.user.rpc;

import com.baomidou.mybatisplus.plugins.Page;
import com.wulian.common.controller.BaseController;
import com.wulian.common.dto.CommonDataDto;
import com.wulian.common.dto.UserInfo;
import com.wulian.common.entity.SysUser;
import com.wulian.user.dto.ResultBulletinBoardLogOutWatchWarningDto;
import com.wulian.user.entity.LogOutWatchWarning;
import com.wulian.user.service.LogOutWatchWarningService;
import io.swagger.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *@Description:()
 * @author  caifulin
 * @date  2020/6/16 13:45
 * @version 1.0
 */

@RestController
@RequestMapping(value = "/LogOutWatchWarning")
public class LogOutWatchWarningController extends BaseController {
    @Autowired
    private LogOutWatchWarningService logOutWatchWarningService;

    @PostMapping("/logOutNum")
    @ApiOperation(value="手机看板-异常登出",httpMethod = "POST",notes="异常登出")
    @ApiResponses(value = { @ApiResponse(code = 200, message = "异常登出") })
    public List<LogOutWatchWarning> logOutNum(@RequestParam("type") String type){
        UserInfo currentUser = getCurrentUser();
        SysUser sysUser = currentUser.getSysUser();
        List<LogOutWatchWarning> logOutWatchWarnings = logOutWatchWarningService.logOutNum(sysUser,type);
        return logOutWatchWarnings;
    }

    @PostMapping("/bulletinBoardlogOutNumByPage")
    @ApiOperation(value="手机看板-异常登出",httpMethod = "POST",notes="异常登出")
    @ApiResponses(value = { @ApiResponse(code = 200, message = "异常登出") })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "num", value = "当前页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "单页数据长度", required = true, dataType = "Integer"),
    })
    public Page<CommonDataDto> bulletinBoardlogOutNumByPage(
            @RequestParam(value="num" , required = true,defaultValue = "1") Integer num,
            @RequestParam(value="pageSize" , required = true,defaultValue = "10")Integer pageSize
    ){
        Page<CommonDataDto> page = new Page<>(num, pageSize);
        UserInfo currentUser = getCurrentUser();
        SysUser sysUser = currentUser.getSysUser();
        List<CommonDataDto> resultBulletinBoardLogOutWatchWarningDtos = logOutWatchWarningService.bulletinBoardlogOutNumByPage(page,sysUser);
        page.setRecords(resultBulletinBoardLogOutWatchWarningDtos);
        return page;
    }

}